<!--
 * @Descripttion: 新增员工
 * @version:
 * @Author: cxguo
 * @Date: 2019-08-17 20:26:23
 * @LastEditors: cxguo
 * @LastEditTime: 2020-11-11 20:27:00
 -->
<template>
  <div>
    <el-form
      ref="form"
      :model="dataObj"
      :rules="rules"
      label-position="right"
      label-width="100px"
      size="mini"
    >
      <div class="w400">
        <el-form-item :label="`员工姓名`">
          <el-input v-model="dataObj.realName" />
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="dataObj.remarks" class="wfull" type="textarea" />
        </el-form-item>
        <el-form-item label="状态">
          <el-switch v-model="dataObj.status" active-value="1" inactive-value="0" />
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>
<script>
import { oftenuse } from '@/libs/mixins'
import { saveData } from '@/api/bsd/guide.js'
import clonedeep from 'clonedeep'

export default {
  name: 'GuideSave',
  components: { },
  mixins: [oftenuse],
  props: {
    data: {
      type: Object,
      default: () => { return null }
    }
  },
  data() {
    return {
      dataObj: { status: '1' },
      optionsData: {},
      rules: {
        realName: [{ required: true, message: '请填写员工姓名！', trigger: 'blur' }]
      }
    }
  },
  computed: {
  },
  watch: {
    'data': {
      handler(data) {
        if (data) {
          this.dataObj = clonedeep(data)
        }
      },
      immediate: true,
      deep: true
    }
  },
  created() {
    this.initData()
  },
  methods: {
    btnSaveData() {

    },
    valiData() {
      const v1 = this.handleValid('form')
      return Promise.all([v1])
    },
    saveData() {
      const params = this.dataObj
      return new Promise(resolve => {
        saveData(params).then(res => {
          resolve(res)
          if (!res.data.flag) return this.$notify.error({ title: '保存失败！' })
          this.$notify.success({ title: '保存成功！' })
        }).catch(err => {
          this.$notify.error({ title: '保存异常！', message: err.message })
        })
      })
    },
    initData() {
    }
  }
}
</script>

<style scoped>
</style>
